﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaobaoMatch
{
    public class Product
    {
        public string ImageUrl { get; set; }
        public string LocalImageUrl { get; set; }
        public string Title { get; set; }
        public double CurrentPrice { get; set; }
        public double DiscountPrice { get; set; }
        public double AfterPrice { get; set; }
        public string ProductDetail { get; set; }
        public string DiscountUrl { get; set; }
        public string Cate { get; set; }
        public string CateName { get; set; }
        public string ID { get; set; }
        public DateTime CreateTime { get; set; }
        public string Description { get; set; }//山西老陈醋，五年陈酿，粮食酿造
        public string Rule { get; set; }//单笔满29.00元可用，每人限领0张
        public int SurplusAmount { get; set; }//优惠券剩余 4996 张
        public int UsedAmount { get; set; }//已领券4张
        public DateTime ExpiredTime { get; set; }//过期日期
        public int TotalAmount { get; set; }//总的数量
        public int SaleAmount { get; set; }//销售量
    }

    #region Response objects

    public class ResponseStatus
    {
        public string Status { get; set; }
        public string Message { get; set; }

        public static ResponseStatus OK()
        {
            return new ResponseStatus()
            {
                Status = "OK",
                Message = string.Empty
            };
        }

        public static ResponseStatus Error(string message)
        {
            return new ResponseStatus()
            {
                Status = "Error",
                Message = message
            };
        }
    }

    public class StringResponse
    {
        public ResponseStatus Status { get; set; }
        public string ResponseStr { get; set; }

        public StringResponse() { }
    }

    public class ObjectResponse
    {
        public ResponseStatus Status { get; set; }
        public Object ResponseObj { get; set; }

        public ObjectResponse() { }
    }

    public class ListResponse
    {
        public ResponseStatus Status { get; set; }
        public List<Object> ResponseList { get; set; }

        public ListResponse() { }
    }

    public class ModelListResponse
    {
        public ResponseStatus Status { get; set; }
        public IList<Product> ResponseList { get; set; }
        public int Count { get; set; }

        public ModelListResponse() { }
    }

    public class DictResponse
    {
        public ResponseStatus Status { get; set; }
        public Dictionary<string, string> ResponseDict { get; set; }

        public DictResponse() { }
    }

    public class ModelList<T> : List<T>
    {
        private int m_totalcount;

        public int TotalCount
        {
            get { return m_totalcount; }
            set { m_totalcount = value; }
        }

        public ModelList(int totalCount)
        {
            m_totalcount = totalCount;
        }

        public ModelList()
        {
        }

        public ModelList<Object> ToListObject()
        {
            ModelList<Object> lst = new ModelList<Object>();
            this.ForEach(x =>
            {
                lst.Add((Object)x);
            });

            return lst;
        }

        public ModelList(int totalCount, List<T> items)
            : this(totalCount)
        {
            foreach (T item in items)
            {
                this.Add(item);
            }
        }
    }

    #endregion
}
